package com.geh.learn.string;

/**
 * Created by gehui on 2017/5/23.
 */
public class StringTest {
    public static void main(String[] args) {
        String a = new String("test");
        String b = new String("test");
        System.out.println("a.hashCode() : " + a.hashCode());
        System.out.println("b.hashCode() : " + b.hashCode());
        System.out.println("a == b "  + (a == b));
        System.out.println("a == b.intern() : " + (a == b.intern()));
        System.out.println("a.intern() == b.intern() : " + (a.intern() == b.intern()));
        System.out.println("a.equals(b) : " + a.equals(b));
        System.out.println("\"test\" == \"test\"  : " + ("test" == "test"));

        String c = "test";
        String d = "test";
        System.out.println("c.hashCode() : " + c.hashCode());
        System.out.println("d.hashCode() : " + d.hashCode());
        System.out.println("c == d : " + (c == d));
    }
}
